#include "CTableConfigure.h"

CTableConfigure::CTableConfigure()
	: m_tableName(""), m_nUpLoadBatchSize(100)
{
	m_nMaxBatchSize = 10 * 1024 * 1024; // Default max batch size 10MB
	m_maxFailedCount = 10; // Default max failed count
}

void CTableConfigure::setTableName(const std::string& tableName)
{
	m_tableName = tableName;
}

std::string CTableConfigure::getTableName() const
{
	return m_tableName;
}

void CTableConfigure::setKeyFields(const std::vector<std::string>& keyFields)
{
	m_uKeyFields = keyFields;
}
void CTableConfigure::setValueFields(const std::vector<std::string>& valueFields)
{
	m_uValueFields = valueFields;
}
std::vector<std::string> CTableConfigure::getKeyFields() const
{
	return m_uKeyFields;
}
std::vector<std::string> CTableConfigure::getValueFields() const
{
	return m_uValueFields;
}

void CTableConfigure::setTableField(CTableField field)
{
	m_TableFieldTypeMap[field.getFieldName()] = field;
}
std::map<std::string, CTableField>& CTableConfigure::getTableFieldTypeMap()
{
	return m_TableFieldTypeMap;
}

int CTableConfigure::getUpLoadRecordCount() const
{
	return m_nUpLoadBatchSize;
}

int CTableConfigure::setUpLoadRecordCount(int size)
{
	if (size > 0)
	{
		m_nUpLoadBatchSize = size;
		return 0;
	}
	return -1;
}

uint64_t CTableConfigure::getMaxBanchSize() const
{
	return m_nMaxBatchSize;
}

void CTableConfigure::setMaxBanchSize(uint64_t size)
{
	if (size > 0)
	{
		m_nMaxBatchSize = size;
	}
}

int CTableConfigure::getMaxFailedCount()
{
	return m_maxFailedCount;	
}

void CTableConfigure::setMaxFailedCount(int nCount)
{
	m_maxFailedCount = nCount;
}
